/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div class="item-title">
      <div class="subject">
        <h3>投诉管理</h3>
        <h5>商城对商品交易投诉管理及仲裁</h5>
      </div>
      <ul class="tab-base nc-row">
        <router-link :to="{name:'complains', params:{state:1}}">
          <li>
            <a>
              <span>新投诉</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complains', params:{state:2}}">
          <li>
            <a>
              <span>对话中</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complains', params:{state:3}}">
          <li>
            <a>
              <span>待仲裁</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complains', params:{state:4}}">
          <li>
            <a>
              <span>已完成</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complain_subject'}">
          <li>
            <a>
              <span>主题设置</span>
            </a>
          </li>
        </router-link>
        <router-link :to="{name:'complain_time'}" active-class="current">
          <li>
            <a>
              <span>时效设置</span>
            </a>
          </li>
        </router-link>
      </ul>
    </div>
    <form :model="form">
      <div class="ncap-form-default">
        <dl class="row">
          <dt class="tit">
            <label>投诉时效</label>
          </dt>
          <dd class="opt">
            <input
              v-model="form.complain_time_limit"
              onkeyup="this.value=this.value.replace(/[^\d.]/g,'');"
              type="text"
              class="input-txt"
            />
            <p
              class="err-msg"
              v-if="errResult.complain_time_limit && !form.complain_time_limit"
            >{{errResult.complain_time_limit}}</p>
            <p class="notic">单位为天，订单完成后开始计算，多少天内可以发起投诉</p>
          </dd>
        </dl>
        <div class="bot">
          <el-button type="primary" @click="onSubmit()" :loading="isLoading">确认提交</el-button>
        </div>
      </div>
    </form>
  </div>
</template>

<script>
import { getConfigs, updateConfigs } from "@/utils/api";
export default {
  data() {
    return {
      form: {},
      isLoading: false,
      errResult: { complain_time_limit: null }
    };
  },
  components: {},
  created() {
    this.getComplainTime();
  },
  methods: {
    getComplainTime() {
      var that = this;
      getConfigs({
        inc_type: "complain"
      }).then(function(res) {
        that.form = res.complain;
      });
    },
    toComplain(state) {
      this.$router.push({
        name: "complains",
        params: {
          state: state
        }
      });
    },
    getSubject() {
      this.$router.push({
        name: "complain_subject"
      });
    },
    onSubmit() {
      if (!this.form.complain_time_limit > 0) {
        this.$message.error("参数错误");
        this.errResult.complain_time_limit = "投诉时效天数必须为大于0";
        return;
      }
      this.isLoading = true;
      var that = this;
      updateConfigs("complain", that.form).then(function(res) {
        if (res.status == 1) {
          that.$message.success("保存成功");
        } else {
          that.$message.error("保存失败,失败原因:" + res.msg);
        }
        that.isLoading = false;
      });
    }
  }
};
</script>

<style scoped>
</style>
